import { PayloadAction, createSlice } from '@reduxjs/toolkit';

type UserState = {
	user: string;
	token: string;
};

const initialState: UserState = {
	user: 'jjqyyds',
	token: ''
};

export const userSlice = createSlice({
	name: 'user',
	initialState,
	reducers: {
		setUser: (state, action: PayloadAction<string>) => {
			state.user = action.payload;
		},
		setToken: (state, action: PayloadAction<string>) => {
			state.token = action.payload;
		}
	}
});

export const { setUser, setToken } = userSlice.actions;

export default userSlice.reducer;
